#pragma once
#include <iostream>
#include <string>
#include <pthread.h>
#include "Lock.hpp"

namespace CondMoudle
{
    using namespace LockModule;

    class cond
    {
    public:
        cond()
        {
            int n = pthread_cond_init(&_cond, nullptr);
            (void)n;
        }
        void wait(Mutex mutex)
        {
            int n = pthread_cond_wait(&_cond, mutex.GetMutexOriginal());
            (void)n;
        }

        void notify()
        {
            int n = pthread_cond_signal(&_cond);
            (void)n;
        }
        void notifyall()
        {
            int n = pthread_cond_broadcast(&_cond);
            (void)n;
        }

        ~cond()
        {
            int n = pthread_cond_destroy(&_cond);
            (void)n;
        }

    private:
        pthread_cond_t _cond;
    };
}